﻿using System;
using System.Linq;
using T.FAS.Runtime.Base.Entity;

namespace T.FAS.Runtime.Action.SGPlugin
{
    internal class TResultCleaner
    {
        /// <summary>
        /// 清理TResult子类TCommonResult<>中的无用属性
        /// </summary>
        /// <param name="result"></param>
        public static void Clean(TResult result)
        {
            //TCommonResult<>为泛型类型，无法提前缓存type
            Type type = result.GetType();
            var properties = type.GetProperties();
            var schemaProp = properties.First(p => p.Name == "Schema");
            schemaProp.SetValue(result, null);
        }
    }
}
